import { createRouter, createWebHistory } from 'vue-router'
import { constRoutes } from './constRoutes'

const generateRoute = () => {
  return createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: constRoutes
  })
}

const router = generateRoute()

export function resetRouter() { //清空路由的方法
  router.getRoutes().forEach((route) => {
    let { name } = route
    if (name != 'login') {      //路由不属于白名单,则删除
      router.hasRoute(name) && router.removeRoute(name);
    }
  });
}
export default router
